package com.itheima.admin.controller;

import com.baomidou.mybatisplus.extension.service.IService;
import com.itheima.admin.dto.ChannelPageRequestDto;
import com.itheima.admin.pojo.AdChannel;
import com.itheima.admin.service.AdChannelService;
import com.itheima.common.vo.PageResultVo;
import com.itheima.common.vo.ResultVo;
import com.itheima.core.controller.AbstractCoreController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/channel")
@Api(tags = "频道管理")
public class AdChannelController extends AbstractCoreController<AdChannel> {

    private AdChannelService adChannelService;

    @Autowired
    public AdChannelController(AdChannelService adChannelService) {
        super(adChannelService);
        this.adChannelService = adChannelService;
    }

    @PostMapping("/list")
    @ApiOperation("频道列表-分页查询")
    public PageResultVo pageList(@RequestBody ChannelPageRequestDto dto){
             PageResultVo vo = adChannelService.pageList(dto);
             return vo;
    }
    //
    ///**
    // * 新增频道
    // * @param adChannel
    // * @return
    // */
    //@PostMapping("/add")
    //@ApiOperation("新增频道")
    //public ResultVo add(@Validated @RequestBody AdChannel adChannel){
    //    adChannelService.add(adChannel);
    //    return ResultVo.ok("SUCCESS");
    //}

    ///**
    // * 通过id查询
    // * @param id
    // * @return
    // */
    //@GetMapping("/{id}")
    //@ApiOperation("通过id查询")
    //public ResultVo findById(@PathVariable int id){
    //    AdChannel adChannel = adChannelService.getById(id);
    //    return ResultVo.ok(adChannel);
    //}
    //
    ///**
    // * 更新频道
    // * @param adChannel
    // * @return
    // */
    //@PostMapping("/update")
    //@ApiOperation("更新频道")
    //public ResultVo update(@RequestBody AdChannel adChannel){
    //    adChannelService.updateById(adChannel);
    //    return ResultVo.ok("SUCCESS");
    //}

    ///**
    // * 通过id删除
    // * @param id
    // * @return
    // */
    //@DeleteMapping("/{id}")
    //@ApiOperation("通过id删除")
    //public ResultVo deleteById(@PathVariable int id){
    //    adChannelService.removeById(id);
    //    return ResultVo.ok("SUCCESS");
    //}
}
